import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:learning/components/LangCard.dart';
import 'package:learning/components/MyText.dart';
import 'package:learning/components/SelectedCard.dart';
import 'package:learning/generated/l10n.dart';

class SelectedAttrebute extends StatefulWidget {
  const SelectedAttrebute({super.key});

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  @override
  State<SelectedAttrebute> createState() => _SelectedAttrebute();
}

class _SelectedAttrebute extends State<SelectedAttrebute> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  void didUpdateWidget(SelectedAttrebute oldWidget) {
    super.didUpdateWidget(oldWidget);
  }

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
    });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.

    return Scaffold(
      primary: true,
      appBar: BrnAppBar(
        backgroundColor: Colors.white,
//默认显示返回按钮
        automaticallyImplyLeading: false,
        //    title: Text("Text"),
        systemOverlayStyle: SystemUiOverlayStyle.dark,
        //自定义的右侧文本
      ),
      body: Container(
          padding: const EdgeInsets.only(bottom: 50),
          child: ListView(children: [
            Container(
                width: MediaQuery.of(context).size.width,
                height: 200,
                alignment: Alignment.center,
                decoration: BoxDecoration(
                  image: DecorationImage(
                    image: AssetImage("assets/image/car.png"),
                    fit: BoxFit.fitHeight,
                  ),
                ),
                child: MyText(
                  S.of(context).app_name,
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 24.0,
                    fontWeight: FontWeight.bold,
                    letterSpacing: 1.5,
                    shadows: [
                      Shadow(
                        blurRadius: 4.0,
                        color: Colors.black,
                        offset: Offset(2.0, 2.0),
                      ),
                      Shadow(
                        blurRadius: 4.0,
                        color: Colors.black,
                        offset: Offset(-2.0, -2.0),
                      ),
                    ],
                  ),
                )),
            Container(
              padding: EdgeInsets.all(15),
              child: LangCard(
                lang: 'ug',
              ),
            ),
            Container(padding: EdgeInsets.all(15), child: SelectedCard(lang: "ug",)),
            SizedBox(height: 5),
            Container(
                width: 400,
                height: 44,
                padding: const EdgeInsets.only(
                    left: 10, top: 0, right: 10, bottom: 0),
                child: ElevatedButton(
                    style: ButtonStyle(
                        // / color: MaterialStateProperty.all(Colors.blue),
                        backgroundColor: MaterialStateProperty.all(Colors.blue),
                        //背景颜色
                        foregroundColor:
                            MaterialStateProperty.all(Colors.red.shade200),
                        //文字颜色
                        shape: MaterialStateProperty.all(RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(6), //设置圆角
                        ))),
                    onPressed: () {
                      Navigator.pushReplacementNamed(context, "/");
                    },
                    child: MyText(S.of(context).home,
                        style: TextStyle(fontSize: 12, color: Colors.white))))
          ])),
    );
  }
}
